/**
 * 
 */
package com.util;

//import java.util.logging.Logger;
import org.apache.log4j.Level;
import org.apache.log4j.Logger;
import org.apache.log4j.xml.DOMConfigurator;

/**
 * @author Kareem.Yehya
 * @since 25 March 2009 * @version 1.0.0.1
 * @This <br>
 *       the logger using the default log4j logger Log <br>
 *       static Level DEBUG <br>
 *       The DEBUG Level designates fine-grained informational events that are most useful to debug an application. <br>
 *       static Level INFO <br>
 *       The INFO level designates informational messages that highlight the progress of the application at coarse-grained level. <br>
 *       static Level WARN <br>
 *       The WARN level designates potentially harmful situations. <br>
 *       static Level ERROR <br>
 *       The ERROR level designates error events that might still allow the application to continue running. <br>
 *       static Level FATAL designates very severe error events that will presumably lead the application to abort. <br>
 *       static Level ALL The ALL Level has the lowest possible rank and is intended to turn on all logging <br>
 *       static Level OFF The OFF Level has the highest possible rank and is intended to turn off logging. <br>
 *       ConsoleAppender: appends log events to System.out or System.err using a layout specified by the user. The default target is System.out. <br>
 *       FileAppender: appends log events to a file. <br>
 *       DailyRollingFileAppender : extends FileAppender so that the underlying file is rolled over at a user chosen frequency. <br>
 *       RollingFileAppender : extends FileAppender to backup the log files when they reach a certain size.
 * 
 *       <param name="ConversionPattern" value="%-5p %c{1} - %m%n" /> <param <param name="ConversionPattern" value="%d %-5p [%c] %m%n" />
 */
public class AWFLogger
{

	private static Logger logger = Logger.getLogger(AWFLogger.class.getName());

	AWFLogger()
	{
		DOMConfigurator.configure("config/AWFE_Log_Conf.xml");
	}

	public static synchronized void error(Object object)
	{
		loadConfiguration();
		if(logger.isEnabledFor(Level.ERROR))
			logger.error(object);
	}

	public static synchronized void info(Object object)
	{
		loadConfiguration();
		if(logger.isEnabledFor(Level.INFO))
			logger.info(object);
	}

	public static synchronized void debug(Object object)
	{
		loadConfiguration();
		if(logger.isEnabledFor(Level.DEBUG))
		{
			logger.debug(object);
		}

	}

	public static synchronized void warn(Object object)
	{
		loadConfiguration();
		if(logger.isEnabledFor(Level.WARN))
		{
			logger.debug(object);
		}

	}

	public static synchronized void fatal(Object object)
	{
		loadConfiguration();
		if(logger.isEnabledFor(Level.FATAL))
		{
			logger.debug(object);
		}

	}

	public static synchronized void showall(Object object)
	{
		loadConfiguration();
		if(logger.isEnabledFor(Level.ALL))
		{
			logger.debug(object);
		}

	}

	public static synchronized void nologging(Object object)
	{
		loadConfiguration();
		if(logger.isEnabledFor(Level.OFF))
		{
			logger.debug(object);
		}

	}

	public static synchronized void loadConfiguration()
	{

		DOMConfigurator.configure("config/AWFE_Log_Conf.xml");

	}

	/**
	 * This part is for testing logging please do not delete
	 * 
	 * @since 25 March 2009
	 * 
	 * **/

	public static void main(String[] args)
	{
		// AWFLogger logger = new AWFLogger();
		// logger.debug("we now in debug");
		// logger.info("we now in info");

	}

}
